package com.example.loopyserver.dao.repository;

import com.example.loopyserver.po.KeywordPO;
import com.example.loopyserver.po.KeywordRelationPO;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface KeywordRepository extends Neo4jRepository<KeywordPO, String> {

    @Query("MATCH (k)-[r]-(k2) WHERE $keyword CONTAINS k.name RETURN type(r) AS relationship, k2.name AS relatedKeyword,k.name AS keyword")
    List<KeywordRelationPO> getKeywordRelations(String keyword);

}
